import {Component, ElementRef, OnInit, ViewChild} from '@angular/core';
import {Globals} from '../../../globals';
import {ApiUrl} from '../../../config/api-url';
import {Chart, registerShape} from '@antv/g2';
import {BaseService} from '../../../shared/service/base.service';

@Component({
  selector: 'app-three',
  templateUrl: './three.component.html',
  styleUrls: ['./three.component.less']
})
export class ThreeComponent implements OnInit {

  type = '2';
  stateAgency = {};
  isMobile = Globals.isMobile();
  dateName = '昨天';
  month = '1';
  disClick = false;
  deviceIsNull = true;
  @ViewChild('ratio') ratio: ElementRef;

  constructor(private baseService: BaseService) {
  }

  ngOnInit(): void {
  }


  /**
   * 统计基本运营情况
   */
  findStateAgency() {
    this.stateAgency = {};
    this.baseService.get(ApiUrl.HomeUrl + '/findStateAgency?type=' + this.type).subscribe(res => {
      if (res.data) {
        this.stateAgency = res.data;
      }
    });
  }

  /**
   * 点击昨天,本月,上月按钮时执行
   */
  operationChange() {
    this.disClick = true;
    this.dateName = this.type == '1' ? '本月' : (this.type == '2' ? '昨天' : (this.type == '-1' ? '上月' : ''));
    this.findStateAgency();
    setTimeout(() => {
      this.disClick = false;
    }, 500);
  }

  /**
   * 扇形图统计按钮点击时执行
   */
  radioChange() {
    // if(this.ratio.nativeElement.innerHTML){
    this.ratio.nativeElement.innerHTML = '';

    // }
  }
}
